<?php


namespace app\common\lib;


use think\Exception;
use think\facade\Log;

class HisData
{
    public static function getHisData(int $type, string $startDate, string $endDate)
    {
        try {
            define("JAVA_DEBUG", true);
            define("JAVA_HOST", "127.0.0.1");
            define("JAVA_LOG_LEVEL", "2");
            require "./Java.inc";
            java_set_encoding("UTF-8");
            $obj = new Java("Hello");
            $result = $obj->ok($type, $startDate, $endDate);
            if (!empty($result)) {
                return json_decode($result, true);
            }
        } catch (\Exception $exception) {
            Log::error("his数据类型{$type}获取异常:" . $exception->getMessage());
        }
    }

    public static function getTypeText($type = 1): array
    {
        $arr = [];
        switch ($type) {
            case 1:
                $arr["collectionName"] = "patient_record";
                $arr["typeText"] = "门诊挂号信息";
                $arr['runMethod'] = 'patientRecord';
                break;
            case 2:
                $arr["collectionName"] = "patient_info";
                $arr["typeText"] = "患者基本信息";
                $arr["runMethod"] = "patientInfo";
                break;
            case 3:
                $arr["collectionName"] = "patient_record";
                $arr["typeText"] = "病案住院信息";
                $arr["runMethod"] = "patientRecord";
                break;
            case 4:
                $arr["collectionName"] = "patient_record";
                $arr["typeText"] = "病案诊断信息";
                $arr["runMethod"] = "patientRecord";
                break;
            case 5:
                $arr["collectionName"] = "patient_record";
                $arr["typeText"] = "病案手术与操作信息";
                $arr["runMethod"] = "patientRecord";
                break;
            case 6:
                $arr["collectionName"] = "patient_record";
                $arr["typeText"] = "医院科室信息";
                $arr["runMethod"] = "patientRecord";
                break;
            case 7:
                $arr["collectionName"] = "patient_record";
                $arr["typeText"] = "医院人员信息";
                $arr["runMethod"] = "patientRecord";
                break;
            case 8:
                $arr["collectionName"] = "patient_record";
                $arr["typeText"] = "出院小结";
                $arr["runMethod"] = "patientRecord";
                break;
        }
        return $arr;

    }


}